[FORMAT "WCOFF"]
[INSTRSET "i486p"]
[OPTIMIZE 1]
[OPTION 1]
[BITS 32]
	EXTERN	_task_run
[FILE "fifo.c"]
[SECTION .text]
	GLOBAL	_fifo32_init
_fifo32_init:
	PUSH	EBP
	MOV	EBP,ESP
	MOV	EAX,DWORD [8+EBP]
	MOV	EDX,DWORD [16+EBP]
	MOV	ECX,DWORD [12+EBP]
	MOV	DWORD [EAX],EDX
	MOV	DWORD [12+EAX],ECX
	MOV	EDX,DWORD [20+EBP]
	MOV	DWORD [16+EAX],ECX
	MOV	DWORD [20+EAX],0
	MOV	DWORD [4+EAX],0
	MOV	DWORD [8+EAX],0
	MOV	DWORD [24+EAX],EDX
	POP	EBP
	RET
	GLOBAL	_fifo32_put
_fifo32_put:
	PUSH	EBP
	MOV	EBP,ESP
	PUSH	EBX
	MOV	EBX,DWORD [8+EBP]
	CMP	DWORD [16+EBX],0
	JNE	L3
	OR	DWORD [20+EBX],1
	OR	EAX,-1
L2:
	MOV	EBX,DWORD [-4+EBP]
	LEAVE
	RET
L3:
	MOV	ECX,DWORD [4+EBX]
	MOV	EDX,DWORD [EBX]
	MOV	EAX,DWORD [12+EBP]
	MOV	DWORD [EDX+ECX*4],EAX
	MOV	EAX,DWORD [4+EBX]
	INC	EAX
	MOV	DWORD [4+EBX],EAX
	CMP	EAX,DWORD [12+EBX]
	JE	L7
L4:
	MOV	EAX,DWORD [24+EBX]
	DEC	DWORD [16+EBX]
	TEST	EAX,EAX
	JE	L5
	CMP	DWORD [4+EAX],2
	JE	L5
	PUSH	0
	PUSH	-1
	PUSH	EAX
	CALL	_task_run
	ADD	ESP,12
L5:
	XOR	EAX,EAX
	JMP	L2
L7:
	MOV	DWORD [4+EBX],0
	JMP	L4
	GLOBAL	_fifo32_get
_fifo32_get:
	PUSH	EBP
	OR	EAX,-1
	MOV	EBP,ESP
	PUSH	ESI
	PUSH	EBX
	MOV	ECX,DWORD [8+EBP]
	MOV	ESI,DWORD [16+ECX]
	MOV	EBX,DWORD [12+ECX]
	CMP	ESI,EBX
	JE	L8
	MOV	EAX,DWORD [8+ECX]
	MOV	EDX,DWORD [ECX]
	MOV	EDX,DWORD [EDX+EAX*4]
	INC	EAX
	MOV	DWORD [8+ECX],EAX
	CMP	EAX,EBX
	JE	L11
L10:
	LEA	EAX,DWORD [1+ESI]
	MOV	DWORD [16+ECX],EAX
	MOV	EAX,EDX
L8:
	POP	EBX
	POP	ESI
	POP	EBP
	RET
L11:
	MOV	DWORD [8+ECX],0
	JMP	L10
	GLOBAL	_fifo32_status
_fifo32_status:
	PUSH	EBP
	MOV	EBP,ESP
	MOV	EDX,DWORD [8+EBP]
	POP	EBP
	MOV	EAX,DWORD [12+EDX]
	SUB	EAX,DWORD [16+EDX]
	RET
